@extends('admin.common.base-master')

@section('html-head')
    <link href="{{url('css/jquery.form.css')}}" type="text/css" rel="stylesheet" />
    <script src="{{url('/js/lib/jquery.form.js')}}"></script>

    <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
    <script type="text/javascript" src="http://code.jquery.com/ui/1.9.1/jquery-ui.min.js"></script>
    <link href="{{url('js/lib/jquery-ui-timepicker-addon.css')}}" type="text/css" />
    <script src="{{url('js/lib/jquery-ui-timepicker-addon.js')}}" type="text/javascript"></script>
    <script src="{{url('js/lib/jquery.ui.datepicker-zh-CN.js')}}" type="text/javascript"></script>
    <script src="{{url('js/lib/jquery-ui-timepicker-zh-CN.js')}}" type="text/javascript"></script>
    <style>
        .btn_add_classify{
            background: #31bcd3;margin-left:10px;height: 5px;width: 50px;color: white;text-align: center;padding:5px;border-radius:7px;box-shadow: 3px 2px 9px #888888;
        }
        .sx{padding: 10px}
        .sx-btn{width: 64px;height: 30px;background-color: #4dbcd3;color: #fff;border: #4dbcd3;border-radius: 7%;}
    </style>
    @include('UEditor::head')
@endsection

@section('html-body')
    <div id="content">
        <!-- cur-position start -->
        <div id="cur-position">
            <span class="tit">当前位置：</span>
            <a href="#">会员管理</a>
        </div>

        <div class="filter-box clearfix">
            <div class="fl" style="display: inline-flex">
                <div class="sx">
                    <span>计划名称：</span>
                    <select style="min-width: 70px;height: 30px" id="select_plan">
                        <option value="0" selected>全部</option>
                        @foreach($plans as $plan)
                            <option value="{{$plan->id}}" @if($plan_id == $plan->id)selected @endif>{{$plan->title}}</option>
                        @endforeach
                    </select>
                </div>
                <div class="sx">
                    <button class="sx-btn" id="sx_btn">筛选</button>
                </div>
            </div>
        </div>
        <div class="table-box">
            <table class="table">
                <thead>
                <tr>
                    <th>ID</th>
                    <th>头像</th>
                    <th>手机</th>
                    <th>昵称</th>
                    <th>生日</th>
                    <th>行业</th>
                    <th>职业</th>
                    <th>地区</th>
                    <th>金额</th>
                    <th>支付时间</th>
                    <th>支付方式</th>
                    <th>状态</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                @if(count($plan_joins) > 0)
                    @foreach($plan_joins as $plan_join)
                        <tr id="planjoin_{{$plan_join->id}}">
                            <td>{{$plan_join->id}}</td>
                            <td class="account-td" style="width: 5%;">
                                <span class="photo" style="border-radius: 100%;display:initial">
                                    <img src="@if($plan_join->userinfo)<?php echo \App\Http\Services\UserManager::getUserPhotoUrl($plan_join->userinfo->photo_id) ?> @endif" alt="">
                                </span>
                            </td>
                            <td>@if($plan_join->user){{$plan_join->user->phone}}@endif</td>
                            <td>@if($plan_join->userinfo){{$plan_join->userinfo->nickname}}@endif</td>
                            <td>{{$plan_join->birthday}}</td>
                            <td>{{$plan_join->trade}}</td>
                            <td>{{$plan_join->job_name}}</td>
                            <td>{{$plan_join->province}}{{$plan_join->city}}{{$plan_join->area}}</td>
                            <td>{{$plan_join->amount}}</td>
                            <td>{{$plan_join->pay_time}}</td>
                            <td>{{$plan_join->pay_type}}</td>
                            <td>@if($plan_join->status == 1 || $plan_join->status == 0)<span class="color4">正常</span> @else锁定 @endif</td>
                            <td>
                                <a class="contact" href="javascript:void(0);" data-id="{{$plan_join->id}}" data-type="{{$plan_join->is_contact}}">@if($plan_join->is_contact == 0)<span style="color: #e9a309">标记联系</span> @else <span style="color: #07800e">已联系</span> @endif</a>
                                <span>|</span>
                                <a href="javascript:void(0);" class="close" data-id="{{$plan_join->id}}">@if($plan_join->status == 0 || $plan_join->status == 1)<span style="color: #515454">锁定</span> @else <span style="color: #961212">解锁</span> @endif</a>
                            </td>
                        </tr>
                    @endforeach
                @endif
                </tbody>
                <tfoot class="order-gl">

                </tfoot>
            </table>
        </div>
    </div>
    <script>
        $(function () {
            $('#sx_btn').click(function () {
                var id = $("#select_plan option:selected").val();
                window.location.href = "{{route('Admin.Home.selectList')}}?plan_id="+id;
            });

            $('.contact').click(function () {
                var id = $(this).data("id");
                var type = $(this).data("type");
                if(type == 1){
                    noty({type:'error',text:"该会员已被标记",timeout:600});
                    return;
                }
                $.ajax({
                    url:'{{route('Api.Admin.Plan.setContact')}}',
                    type:'post',
                    dataType:'json',
                    data:{id:id},
                    success:function(obj){
                        if(obj.level == "success"){
                            noty({text:obj.message,type:obj.level,timeout:600,
                                callback:{
                                    afterClose:function(){
                                        window.location.reload();
                                    }
                                }
                            });
                        }else{
                            noty({type:obj.level,text:obj.message,timeout:600});
                        }
                    },
                    error:function(obj){
                        console.log(obj);
                    }

                });
            });


            $('.close').click(function () {
                var id = $(this).data("id");
                $.ajax({
                    url:'{{route('Api.Admin.Plan.setClose')}}',
                    type:'post',
                    dataType:'json',
                    data:{id:id},
                    success:function(obj){
                        if(obj.level == "success"){
                            noty({text:obj.message,type:obj.level,timeout:600,
                                callback:{
                                    afterClose:function(){
                                        window.location.reload();
                                    }
                                }
                            });
                        }else{
                            noty({type:obj.level,text:obj.message,timeout:600});
                        }
                    },
                    error:function(obj){
                        console.log(obj);
                    }

                });
            });
        });
    </script>
@endsection